import { NextRequest, NextResponse } from 'next/server'
import { getCasdoorLoginUrl } from '@/lib/casdoor'

export async function GET(request: NextRequest) {
  const { searchParams } = new URL(request.url)
  const redirectUri = `${process.env.NEXTAUTH_URL}/api/auth/callback`
  const state = searchParams.get('state') || 'login'
  
  const loginUrl = getCasdoorLoginUrl(redirectUri, state)
  
  return NextResponse.redirect(loginUrl)
} 